﻿#include "ChatNoticeDialog.h"
#include "../../MirGraphics/MLibrary.h"
#include "../../Settings.h"
#include "../../Forms/Client.CMain.h"

using namespace Client::MirControls;
using namespace Client::MirGraphics;
using namespace Client::MirSounds;

namespace Client::MirScenes::Dialogs
{

    ChatNoticeDialog::ChatNoticeDialog()
    {
        setIndex(1361);
        setLibrary(Libraries::Prguse);
        setMovable(false);
        setSort(false);
        Point tempVar(Settings::ScreenWidth / 2 - getSize()->Width / 2, Settings::ScreenHeight / 6 - getSize()->Height / 2);
        setLocation(&tempVar);
        setOpacity(0.7F);

        TextLabel1 = new MirLabel();
        TextLabel1->setText("");
        Font tempVar2(Settings::FontName, 10.0F);
        TextLabel1->setFont(&tempVar2);
        TextLabel1->setDrawFormat(TextFormatFlags::VerticalCenter | TextFormatFlags::HorizontalCenter);
        TextLabel1->setParent(this);
        TextLabel1->setNotControl(true);
        Point tempVar3(0, -6);
        TextLabel1->setLocation(&tempVar3);
        Size tempVar4(660, 40);
        TextLabel1->setSize(&tempVar4);
        TextLabel1->setForeColour(Color::Yellow);
        TextLabel1->setOutLineColour(Color::Black);

        TextLabel2 = new MirLabel();
        TextLabel2->setText("");
        Font tempVar5(Settings::FontName, 15.0F);
        TextLabel2->setFont(&tempVar5);
        TextLabel2->setDrawFormat(TextFormatFlags::VerticalCenter | TextFormatFlags::HorizontalCenter);
        TextLabel2->setParent(this);
        TextLabel2->setNotControl(true);
        Point tempVar6(0, 0);
        TextLabel2->setLocation(&tempVar6);
        Size tempVar7(660, 40);
        TextLabel2->setSize(&tempVar7);
        TextLabel2->setForeColour(Color::Yellow);
        TextLabel2->setOutLineColour(Color::Black);

        Layout = new MirImageControl();
        Layout->setIndex(1360);
        Layout->setLibrary(Libraries::Prguse);
        Point tempVar8(0, 0);
        Layout->setLocation(&tempVar8);
        Layout->setParent(this);

        AfterDraw += ChatNotice_AfterDraw;
    }

    void ChatNoticeDialog::ChatNotice_AfterDraw(std::any sender, EventArgs *e)
    {

        if (CurrentTime < CMain::Time)
        {
            Hide();
        }
    }

    void ChatNoticeDialog::ShowNotice(const std::string &text, int type)
    {
        setIndex(type == 0 ? 1361 : 1363);
        Layout->setIndex(type == 0 ? 1360 : 1362);
        TextLabel2->setText(text);
        TextLabel1->setText(TextLabel2->getText());
        TextLabel1->setVisible(type == 0);
        TextLabel2->setVisible(type == 1);

        Show();
        CurrentTime = CMain::Time + ViewTime;
    }
}
